package dialer.client.web.controlador;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.apache.log4j.Logger;

import dialer.ws.base.entity.Campaign;
import dialer.ws.base.entity.vtelcom.ColumnType;
import dialer.ws.base.entity.vtelcom.Script;
import dialer.ws.base.exception.EntityException;
import dialer.ws.business.service.CampaignService;
import dialer.ws.business.service.ColumnTypeService;
import dialer.ws.business.service.ScriptService;

public class InitLoad {

	protected Logger log = Logger.getLogger(getClass());

	private List<ColumnType> listColumnType;
	private List<SelectItem> siColumnType;
	
	private List<Campaign> listCampaign;
	private List<SelectItem> siCampaign;
	
	private List<Script> listScript;
	private List<SelectItem> siScript;
	
	private ColumnTypeService columnTypeService;
	private CampaignService campaignService;
	private ScriptService scriptService;
	
	public InitLoad() {
		listColumnType = new ArrayList<ColumnType>();
		siColumnType = new ArrayList<SelectItem>();
		
		listCampaign = new ArrayList<Campaign>();
		siCampaign = new ArrayList<SelectItem>();
		
		listScript = new ArrayList<Script>();
		siScript = new ArrayList<SelectItem>();
	}

	public void init() throws EntityException {
		listColumnType = columnTypeService.findAll();
		for (ColumnType item : listColumnType) {
			SelectItem it = new SelectItem(item.getId(), item.getName());
			siColumnType.add(it);
		}
		
		listCampaign = campaignService.getCampaignByState("A");
		for (Campaign item : listCampaign) {
			SelectItem it = new SelectItem(item.getId(), item.getName());
			siCampaign.add(it);
		}
		
		listScript = scriptService.findAll();
		for (Script item : listScript) {
			SelectItem it = new SelectItem(item.getId(), item.getName());
			siScript.add(it);
		}
	}

	public List<Campaign> getListCampaign() {
		return listCampaign;
	}

	public void setListCampaign(List<Campaign> listCampaign) {
		this.listCampaign = listCampaign;
	}

	public List<SelectItem> getSiCampaign() {
		return siCampaign;
	}

	public void setSiCampaign(List<SelectItem> siCampaign) {
		this.siCampaign = siCampaign;
	}

	public CampaignService getCampaignService() {
		return campaignService;
	}

	public void setCampaignService(CampaignService campaignService) {
		this.campaignService = campaignService;
	}

	

	public ColumnTypeService getColumnTypeService() {
		return columnTypeService;
	}

	public void setColumnTypeService(ColumnTypeService columnTypeService) {
		this.columnTypeService = columnTypeService;
	}

	public List<ColumnType> getListColumnType() {
		return listColumnType;
	}

	public void setListColumnType(List<ColumnType> listColumnType) {
		this.listColumnType = listColumnType;
	}

	public List<SelectItem> getSiColumnType() {
		return siColumnType;
	}

	public void setSiColumnType(List<SelectItem> siColumnType) {
		this.siColumnType = siColumnType;
	}

	public List<Script> getListScript() {
		return listScript;
	}

	public void setListScript(List<Script> listScript) {
		this.listScript = listScript;
	}

	public List<SelectItem> getSiScript() {
		return siScript;
	}

	public void setSiScript(List<SelectItem> siScript) {
		this.siScript = siScript;
	}

	public ScriptService getScriptService() {
		return scriptService;
	}

	public void setScriptService(ScriptService scriptService) {
		this.scriptService = scriptService;
	}

}
